package Views;

import Dao.OnePara;
import Dao.ScoreDao;
import Model.StudentCourse;
import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author 李宝瑞
 * 添加学生信息
 *
 */
public class AddStuInfoView {
    public void mainView() {
        OnePara onePara = new OnePara();
        Scanner input = new Scanner(System.in);
        ScoreDao scoreDao = new ScoreDao();
        System.out.println("执行添加学生信息");
        System.out.println("****************************************");
        System.out.println("\n\t\t1.添加学生\n");
        System.out.println("\t\t2.添加学生成绩\n");
        System.out.println("****************************************");
        System.out.println("请选择,输入数字或者按0返回上一级菜单：");
        int number = input.nextInt();
        switch (number) {
            case 0:
                StudentView studentView = new StudentView();
                studentView.mainView();
                break;
            case 1:
                String flag1 = "";
                do {
                    System.out.println("请输入学生姓名：");
                    String stuName = input.next();
                    onePara.insertStudent(stuName);
                    System.out.println("添加成功！ 是否继续，y or n");//没有检测是否成功。。。。反正就是成功。。。
                    flag1 = input.next();

                } while ("y".equals(flag1));
                break;
            case 2:
                String flag2 = "";
                do {
                    System.out.println("请输入学生姓名：");
                    String stuName = input.next();
                    System.out.println("请输入选择添加的科目：");
                    String courseInsert = input.next();
                    System.out.println("请输入学生成绩：");
                    int scoreInsert = input.nextInt();
                    Boolean isOk = scoreDao.changeScore(courseInsert,stuName,scoreInsert);
                    if (isOk) {
                        System.out.println("添加成功！ 是否继续，y or n");//没有检测是否成功。。。。反正就是成功。。。
                        flag2 = input.next();
                    }
                    else {
                        flag2 = "y";
                    }
                }
                while ("y".equals(flag2));
                break;

        }
    }
}